package cn.cloud.service;

import cn.cloud.dao.ItemDescMapper;
import cn.cloud.dao.ItemMapper;
import cn.cloud.pojo.Item;
import cn.cloud.pojo.ItemDesc;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by Cloud on 2017/9/24 0024.
 */
@Service
public class ItemServiceImpl extends BaseServiceImpl<Item> implements ItemService {
    @Autowired
    private ItemMapper itemMapper;
    @Autowired
    private ItemDescMapper itemDescMapper;

    public void add(Item item, String desc) {
        item.setId(null);
        item.setStatus(1);
        Date date = new Date();
        item.setUpdated(date);
        item.setCreated(date);
        itemMapper.insert(item);
        ItemDesc itemDesc = new ItemDesc();
        itemDesc.setItemId(item.getId());
        itemDesc.setItemDesc(desc);
        itemDescMapper.insert(itemDesc);
    }

    @Override
    public List<Item> queryHotList() {
        return itemMapper.queryHotList();
    }
}
